<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html class="no-js">
<%@page import="java.sql.*"%>
<%@page import="com.otc.controller.LoginController"%>
<%@page import="com.otc.model.*"%>
<%@page import="com.otc.model.Movies"%>
<%@page import="com.otc.utility.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%-- // load our paging tag, pass pagedListHolder and the link --%>
<tg:paging pagedListHolder="${pagedListHolder}" pagedLink="${pagedLink}"/>
<%-- // show only current page worth of data --%>

<head>
<meta charset="utf-8" />
<title>Opinion That Counts - Movies</title>
<link rel="stylesheet" media="all" href="css/style.css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<%@ include file="/WEB-INF/jsp/Common/Header.jsp"%>
<script src="/js/Movies.js"></script>


<script>
	var movieName = new Array();
	var movieLikes = new Array();
	var movieDislikes = new Array();
	var movieImage = new Array();
	var movieRating = new Array();
	var movieSubmitDate = new Array();
	var movieDescription = new Array();
	var movieId		= new Array();
	var userId		= new Array();

	<c:forEach var="entry" items="${message}">
	movieName.push("${entry.getMoviename()}");
	movieLikes.push("${entry.getMovieLikes()}");
	movieDislikes.push("${entry.getMovieDislikes()}");
	movieImage.push("${entry.getMovieImage()}");
	movieRating.push("${entry.getMovieRating()}");
	movieSubmitDate.push("${entry.getMovieSubmitDate()}");
	movieDescription.push("${entry.getMovieDesc()}");
	movieId.push("${entry.getMovieId()}");
	userId.push("${entry.getMovieUserId()}");
	</c:forEach>

	var username = new Array();
	<c:forEach var="uid" items="${username}">
	username.push("${uid}");
	</c:forEach>

	function creatediv(id, divClass, elementId, divinnertHtml) {
		var newdiv = document.createElement('div');
		newdiv.setAttribute('id', id);
		newdiv.setAttribute('class', divClass);
		newdiv.innerHTML = divinnertHtml;
		document.getElementById(elementId).appendChild(newdiv);
	}

	function createarticle(i) {
		var newarticle = document.createElement('article');
		newarticle.setAttribute('class', 'format-standard');
		newarticle.setAttribute('id', 'post-article' + i);
		document.getElementById('posts-list').appendChild(newarticle);
	}
	
	
	function main(i, var1, var3, var2, var4, var5, var6, var7, var8,var9,var10) {
		var day = new Date(var6);

		var month = new Array();
		month[0] = "JAN";
		month[1] = "FEB";
		month[2] = "MAR";
		month[3] = "APR";
		month[4] = "MAY";
		month[5] = "JUN";
		month[6] = "JUL";
		month[7] = "AUG";
		month[8] = "SEP";
		month[9] = "OCT";
		month[10] = "NOV";
		month[11] = "DEC";

		createarticle(i);
		creatediv(
				'post-image',
				'feature-image',
				'post-article' + i,
				'<a href="<c:url value="/single.html?id10='+ var9+ '" />"> <img src="/OpinionThatCounts/resources/img/movies/hollywood/'+var4+'" alt="Alt text" /></a>');
		creatediv('post-data' + i, 'box cf', 'post-article' + i, '');
		creatediv('post-date', 'entry-date', 'post-data' + i,
				'<div class="number">' + day.getDate()
						+ '</div><div class="month">' + month[day.getMonth()]
						+ '</div>');
		creatediv('post-heading', 'excerpt', 'post-data' + i,
				'<a href="single.jsp" class="post-heading">' + var1 + '</a><p>'
						+ var8 + '....' + '</p>');
		creatediv(
				'post-meta',
				'meta',
				'post-data' + i,
				'<span class="user"><ahref="#">By '
						+ var7
						+ ' </a></span> <span class="comments">100 comments</span><span class="like-dislike">'
						+ '<table><tr><td><input name="submit" type="image" src="img/like.png";"></td>'
						+ '<td id="likes">'+var2+'</td><td style="padding-right:10px;"></td><td><a href=dislike.html><img src="img/dislike.png" style="padding-right:5px;"/></a></td>'
						+ '<td>'+var3+'</td></tr></table>'
						+ '</span> <span class="ratings">Overall Rating '
						+ var5 + '/10</span> ');
	}

	function test() {
		for (i = 0; i < movieName.length; i++) {
			main(i, movieName[i], movieDislikes[i], movieLikes[i],
					movieImage[i], movieRating[i], movieSubmitDate[i],
					username[i], movieDescription[i],movieId[i],userId[i]);
		}
	}
</script>
<script>
	$(document).ready(function() {
		$("#movies").addClass("current-menu-item");
	});
</script>

</head>
<body class="blog" onload="test();">

	<!-- MAIN -->
	<div id="main">
		<div class="wrapper cf" id="wrapper">

			<!-- posts list -->
			<div id="posts-list" class="cf"></div>
			<!-- ENDS WRAPPER -->
			<%@ include file="/WEB-INF/jsp/Common/Sidebar.jsp"%>

		</div>
	</div>
	<!-- ENDS MAIN -->

	<%@ include file="/WEB-INF/jsp/Common/Footer.jsp"%>
</body>
</html>